// 登录页面数据


import Mock from "mockjs"


// 设置固定的账号密码
let userInfo = [
    {
        username:'张昆',
        password:'123',
    },
    {
        username:'宋子强',
        password:'123',

    },
    {
        username:'黄贤良',
        password:'123',
    },
]

Mock.mock('/login','post',(data)=>{
    const req = JSON.parse(data.body)
    let res = {
        code:'200',
        msg:'登录成功'
    }
    // console.log(req);
    for (let i = 0; i < userInfo.length; i++) {

        const item = userInfo[i]
        // console.log(item);

        if(item.username === req.username){
            if(item.password === req.password){
                res.code='200'
                res.msg = '登录成功'
                res.token = '123456789'
                return res
            }else{
                res.code = '2001'
                res.msg='密码错误';
            }
        }else{
            res.code = '2002'
            res.msg='账号不存在';
        }
    }
    return res
})


   